import {getCookie, setCookie } from '@/utils/cookie'

const state = {
    sidebar: {
        opened: getCookie('sidebarStatus') ? true : false,
        withoutAnimation: false
    },
    device: 'desktop'
}

const mutations = {
    toggleSidebar: state => {
        state.sidebar.opened = !state.sidebar.opened
        state.sidebar.withoutAnimation = false
        if (state.sidebar.opened) {
            setCookie('sidebarStatus', 1)
        } else {
            setCookie('sidebarStatus', 0)
        }
    }
}

const actions = {
    toggleSideBar ({ commit }) {
        console.log(11211)
        commit('toggleSidebar')
    }
}


export default {
    namespaced: true,
    state,
    mutations,
    actions
}